<template>
  <div>
    <div class="flex">
      <div>
        <el-checkbox v-model="checkAll" label="全选" size="large" />
      </div>
      <div class="mar-l-20">
        <el-button type="text">导出</el-button>
      </div>
    </div>
    <div class="mar-t-15">
      <div class="list-header font-14 font-w flex">
        <span>商品</span>
        <span>颜色/尺码</span>
        <span>购买数/配送数</span>
        <span>总金额</span>
        <span>订单状态</span>
        <span>操作</span>
      </div>
      <div v-for="(item, index) of dataList" :key="index" class="mar-t-10">
        <div class="order-info flex flex-between pad-l-10 pad-r-20">
          <div class="v-align-c">
            <el-checkbox v-model="checkAll" size="large" />
            <span class="mar-l-10 font-12">订单号: {{ item.orderNo }} </span>
            <span class="mar-l-10 font-12 font-color-9">{{
              item.createTime
            }}</span>
            <!-- <span class="mar-l-13 font-12 address-tag v-align-c">杭州</span> -->
          </div>
          <div class="v-align-c font-12 user-info">
            <span>收件人：{{ item.customerNickname }}</span>
            <span class="mar-l-15">手机号：{{ item.customerPhone }}</span>
          </div>
        </div>
        <div class="goods-info pad-t-13 pad-b-20 flex">
          <div class="flex pad-l-10">
            <img class="width-80 height-80" :src="item.goodsImageUrl" alt="">
            <div class="flex-col mar-l-10">
              <span class="font-12 font-color-3 line-1 goods-title">{{
                item.goodsTitle
              }}</span>
              <span
                class="font-12 font-color-6 mar-t-4"
              >货号：{{ item.goodsCode }}</span>
              <span
                class="font-12 font-color-6"
              >单价：<span class="count">￥{{ item.goodsPrice }}</span></span>
              <!-- <span class="font-12 fast-tag flex flex-center mar-t-5">闪电下单</span> -->
            </div>
          </div>
          <div>
            <span class="font-12 font-color-6">{{ item.skuDetail }}</span>
          </div>
          <div>
            <span
              class="font-12 font-color-6"
            >{{ item.goodsNum }} / {{ item.deliveryNum }}</span>
          </div>
          <div class="flex-col">
            <span class="font-14 font-color-3">￥{{ item.orderPrice }}</span>
            <span
              class="font-12 font-color-6 mar-t-4"
            >含运费{{ item.freight }}</span>
          </div>
          <div class="flex-col">
            <span class="font-12 font-color-6">{{ dict.orderStatus[item.orderStatus] }}</span>
            <router-link :to="{ name: 'my-order-detail', query: {apartOrderId: item.apartOrderId}}">
              <span class="font-12 font-color-3 mar-t-6 cursor-p">订单详情</span>
            </router-link>
          </div>
          <div class="flex-col font-12">
            <span v-if="item.orderStatus === 2" class="cursor-p btn-color">确认收货</span>
            <span
              v-if="item.orderStatus === 1 || item.orderStatus === 2 || item.orderStatus === 3 || item.orderStatus === 20"
              class="cursor-p btn-color mar-t-6"
              @click="applyAfterSale(item.orderGoodsId)"
            >申请售后</span>
          </div>
        </div>
      </div>
      <!-- 空数据展示 -->
      <div>
        <none-data v-if="dataList.length <= 0" />
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue'
import { getDictByGroupName } from '@/api/common/common'
import noneData from '@/components/noneData/index.vue'
import { useRouter } from 'vue-router'

export default defineComponent({
  name: '',
  components: {
    noneData
  },
  props: {
    dataList: Object
  },
  setup() {
    const router = useRouter()
    const checkAll = ref(false)
    const dict = ref({
      orderStatus: {}
    })
    onMounted(() => {
      initDict()
    })

    const initDict = () => {
      // 获取数据字典
      getDictByGroupName('ProjectOrderDTO').then((response) => {
        Object.assign(dict.value, response.data)
      })
    }
    // 跳转售后页面
    const applyAfterSale = (orderGoodsId:string) => {
      router.push({
        path: '/center/apply-after-sales',
        query: {
          orderGoodsId: orderGoodsId
        }
      })
    }

    return {
      checkAll,
      dict,
      applyAfterSale
    }
  }
})
</script>

<style lang="scss" scoped>
$darkBlue: #182245;
$fontcolor: #323233;
$td1: 371px;
$td2: 149px;
$td3: 228px;
$td4: 105px;
$td5: 144px;
.list-header {
  width: 1140px;
  height: 48px;
  background: #f9f9f9;
  border: 1px solid #f5f5f5;
  color: $fontcolor;
  & > span {
    display: flex;
    align-items: center;
  }
  & > span:nth-child(1) {
    padding-left: 50px;
    width: $td1;
  }
  & > span:nth-child(2) {
    width: $td2;
  }
  & > span:nth-child(3) {
    width: $td3;
  }
  & > span:nth-child(4) {
    width: $td4;
  }
  & > span:nth-child(5) {
    width: $td5;
  }
}
.order-info {
  width: 1140px;
  height: 34px;
  background: #f5f7fb;
  .address-tag {
    background: $darkBlue;
    color: #fff;
    padding: 1px 5px;
  }
}
.user-info {
  color: $fontcolor;
}
.goods-info {
  & > div:not(:first-child) {
    margin-top: 7px;
  }
  & > div:nth-child(1) {
    width: $td1;
  }
  & > div:nth-child(2) {
    width: $td2;
  }
  & > div:nth-child(3) {
    width: $td3;
  }
  & > div:nth-child(4) {
    width: $td4;
  }
  & > div:nth-child(5) {
    width: $td5;
  }
  .goods-title {
    width: 189px;
  }
  .count {
    color: #ff452c;
  }
  .fast-tag {
    width: 52px;
    height: 16px;
    border: 1px solid #ff7300;
    color: #ff7300;
  }
  .btn-color {
    color: #409eff;
  }
}
</style>

